<template>
	<view class="main">
		<view class="topArea">
			<view class="taName">门店评价</view>
			<view class="taScores">
				<sx-rate :value="Number(scoreNum)" @change="giveScore"/>
			</view>
		</view>
		<view class="middleArea">
			<view class="title">- 具体说说看 -</view>
			<view class="content">
				<textarea value="" placeholder="说些什么吧..." @input="commentContent"/>
			</view>
			<view class="submitBtn" @click="submit">立即提交</view>
		</view>
	</view>
</template>

<script>
  import SxRate from '@/components/sx-rate'
	export default {
		components:{
			SxRate
		},
		data() {
			return {
				title: 'Hello',
				commentCon:'',
				scoreNum: 0,
				id:''
			}
		},
		onLoad(option) {
			this.id = option.id;
		},
		methods: {
			//输入评论内容
			commentContent(e) {
				console.log(e.detail.value);
				this.commentCon = e.detail.value;
			},
			// 打分
			giveScore(event) {
				this.scoreNum = event;
			},
 			submit(){
				if(this.scoreNum == 0) {
					uni.showToast({
						title:'请给门店打分',
						icon: 'none'
					})
					return
				}
				if(this.commentCon == '') {
					uni.showToast({
						title:'请输入评价内容',
						icon: 'none'
					})
					return
				}
				this.$get('customer_item_pingjia.ashx',{
						customer_item_id: this.id,
						Pj_score: this.scoreNum,
						Pj_memo: this.commentCon
					},(res)=>{
						if(res.data == 1) {
							uni.showToast({
							   title: '提交成功！',
							});
							uni.switchTab({url:"/pages/my/my"})
						}else{
							uni.showToast({
							   title: '提交失败！',
							});
						}
					})
				
			}
		}
	}
</script>

<style>
	.content{
		height: 100%;
	}
	.topArea {
		height: 80rpx;
		line-height: 80rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 24rpx;
		background: #fff;
		margin: 16rpx 0;
	}
	.taName {
		font-size: 30rpx;
		color: #000;
	}
	.title {
		height: 74rpx;
		line-height: 74rpx;
		text-align: center;
		background: #fff;
		color: #999999;
	}
	.middleArea {
		background: #fff;
	}
	.middleArea textarea {
		height: 283rpx;
		padding: 24rpx;
	}
	.submitBtn {
		width: 540rpx;
		height: 84rpx;
		line-height: 84rpx;
		text-align: center;
		color: #fff;
		font-size: 32rpx;
		border-radius: 10rpx;
		background: #008afd;
		margin: 0 auto;
	}
</style>
